import commonList from '@/components/common/commonList'
export default {

	data() {
		return {
			Inv: 0,
			tableData: [],
			userInfo: {},

			table_config: [{
					label: "样品编号",
					prop: "fSampleassignnostr",
					isLine: false,

				},
				{
					label: "闭合状态",
					prop: "fClosestatus",
					isLine: false,
				},
				{
					label: "试验名称",
					prop: "fSamplereportname",
					isLine: true,
				},

				{
					label: "项目简称",
					prop: "fProjectname",
					isLine: true,
				},
				{
					label: "报告编号",
					prop: "fSamplereportnostr",
					isLine: true,
				},
				{
					label: "报告日期",
					prop: "fReportdates",
					isLine: true,
				},


			],
			AduitUser: null, //审核流程
			dataList: {
				fCompanyid: "", //左侧选中组织机构id
				userId: "", //查询待办或已办时传 列表页查询不传
				fCheckStatus: "", // 当前登录用户机构性质 和流程配置字段比对结果
				modelType: "", //0待办 1已办
			},

		}
	},
	components: {
		commonList,
	},
	onLoad(option) {
		var that = this;

		if (option.Inv) {
			this.Inv = option.Inv;
		}

		uni.getStorage({
			key: 'userInfo',
			success: function(res) {
				that.userInfo = JSON.parse(res.data);
				that.getExamine(that.userInfo.companyId);
			}
		})
	},
	onShow() {
		var that = this
		if (that.Inv == 0) {
			setTimeout(() => {
				that.unsubmit()
			}, 300)
		}
		if (that.Inv == 1) {
			setTimeout(() => {
				that.submit()
			}, 300)
		}
	},

	// 新增
	onNavigationBarButtonTap(e) {},
	// 返回
	onBackPress(event) {
		uni.switchTab({
			url: '/pages/home/index'
		});
		return true;
	},

	methods: {
		unsubmit() {
			var that = this;
			this.Inv = 0;
			this.yj_searchForm(this.Inv);
		},
		submit() {
			var that = this;
			this.Inv = 1;
			this.yj_searchForm(this.Inv);
		},
		// 获取审核流程
		getExamine(data) {
			this.$http.SamplegetStationWarnByCompanyId({
					fCompanyid: data
				})
				.then((res) => {
					if (res.errcode == 0) {
						this.AduitUser = res.data.yjQmpMsCheckSamplewarn.fAduitUser1.split("-");
					}
				})
				.catch((error) => {
					console.log(error);
				});
		},
		// 获取列表
		yj_searchForm(num) {
			num = num.toString()
			this.dataList = {
				fCompanyid: this.userInfo.companyId, //左侧选中组织机构id
				userId: this.userInfo.userId, //查询待办或已办时传 列表页查询不传
				fCheckStatus: "", // 当前登录用户机构性质 和流程配置字段比对结果
				modelType: num, //0待办 1已办
			};
			this.AduitUser.map((item, index) => {
				if (item == this.userInfo.companyNature) {
					this.dataList.fCheckStatus = index.toString();
				}
			})

			this.$http.getSampleTestWorkAppList(this.dataList).then(res => {
				if (res.errcode == 0) {
					var that = this;
					that.tableData = [];
					that.tableData = res.data.checkSampleList;
				} else {
					console.log("接口报错")
				}
			}, (err) => {
				uni.showToast({
					title: "获取数据失败",
					icon: 'none',
					duration: 2000
				});
			})

		},
		// 查看
		yj_viewForm(e) {
			if (e.Inv == 0) {
				uni.navigateTo({
					url: "/pages/apply/testDetectionManage/unqualifiedReport/inter/index?id=" + e.id +
						"&fCompanyid=" +
						this.dataList.fCompanyid + "&Look=" + this.dataList.fCheckStatus
				});
				return false;
			}
			
			if (e.Inv == 1) {
				uni.navigateTo({
					url: "/pages/apply/testDetectionManage/unqualifiedReport/submit/index?id=" + e.id +
						"&fCompanyid=" +
						this.dataList.fCompanyid + "&Look=" + this.dataList.fCheckStatus
				});
				return false;
			}

		},
	}
}
